package main

import (
	"database/sql"
	_ "github.com/go-sql-driver/mysql"
	"log"
	"net/http"
	"trainingGo/app"
	"trainingGo/base"
)

func main() {
	db, err := sql.Open("mysql", "root:lsw910606@tcp(127.0.0.1:3306)/goTraining")
	if err != nil {
		log.Fatal(err)
		return
	}
	defer db.Close()

	err = db.Ping()
	if err != nil {
		log.Fatal(err)
		return
	}

	base.Set(db)
	app.SetRouter()
	err = http.ListenAndServe(":8080", app.GetEngine())
	if err != nil {
		log.Fatal(err)
	}
}
